package com.freesky.biz.icbc.controller;

import com.freesky.biz.icbc.domain.TSocialCard;
import com.freesky.biz.icbc.service.ISocialCardService;
import com.freesky.common.annotation.Log;
import com.freesky.common.annotation.RepeatSubmit;
import com.freesky.common.core.controller.BaseController;
import com.freesky.common.core.domain.AjaxResult;
import com.freesky.common.core.page.TableDataInfo;
import com.freesky.common.enums.BusinessType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 社保卡业务
 */
@RestController
@RequestMapping("/icbc/socialcard")
public class SocialCardController extends BaseController {

    @Autowired
    private ISocialCardService socialCardService;

    /**
     * 社保卡列表
     */
    @PreAuthorize("@ss.hasPermi('icbc:socialcard:list')")
    @GetMapping("/list")
    public TableDataInfo list(TSocialCard socialCard) {
        startPage();
        List<TSocialCard> list = socialCardService.findList(socialCard);
        return getDataTable(list);
    }

    @RepeatSubmit
    @Log(title = "社保卡", businessType = BusinessType.EXPORT)
    @PreAuthorize("@ss.hasPermi('icbc:socialcard:export')")
    @GetMapping("/export")
    public AjaxResult export(TSocialCard socialCard,
                             HttpServletResponse response) {
        return socialCardService.exportFile(socialCard);
    }

}
